package org.tomcat.unit502;

import javax.servlet.ServletException;
import java.io.IOException;

public class ClientIPLoggerValve implements Valve, Contained {

    protected Container container;

    @Override
    public Container getContainer() {
        return this.container;
    }

    @Override
    public void setContainer(Container container) {
        this.container = container;
    }

    @Override
    public String getInfo() {
        return null;
    }

    @Override
    public void invoke(Request request, Response response, ValveContext context) throws IOException, ServletException {
        System.out.print("Client IP Logger Valve : ");
        String remoteAddr = request.getRequest().getRemoteAddr();
        System.out.println(remoteAddr);
        System.out.println("----------------------------------------");
        context.invokeNext(request, response);
    }
}
